Header file visitor.hpp

namespace type_safe
{
    template <typename Visitor, class ... Optionals>
    'hidden' visit(Visitor&& visitor, Optionals&&... optionals);
    
    template <class Visitor, class ... Variants, typename = typename std::enable_if<detail::all_of<detail::is_variant<Variants>::value...>::value>::type>
    decltype(detail::visit_variant(std::forward<Visitor>(visitor), std::forward<Variants>(variants)...)) visit(Visitor&& visitor, Variants&&... variants);
}

Function template type_safe::visit [optional]

template <typename Visitor, class ... Optionals>
'hidden' visit(Visitor&& visitor, Optionals&&... optionals);

Visits a ts::basic_optional.

Effects: Effectively calls visitor((optionals.has_value() ? optionals.value() : nullopt)...), i.e. the operator() of visitor passing it sizeof...(Optionals) arguments, where the ith argument is the value() of the ith optional or nullopt, if it has none. If the particular combination of types is not overloaded, the program is ill-formed, unless the Visitor provides a member named incomplete_visitor, then visit() does not do anything instead of the error.

Returns: The result of the chosen operator(), its the type is the common type of all possible combinations.

Function template type_safe::visit

template <class Visitor, class ... Variants, typename = typename std::enable_if<detail::all_of<detail::is_variant<Variants>::value...>::value>::type>
decltype(detail::visit_variant(std::forward<Visitor>(visitor), std::forward<Variants>(variants)...)) visit(Visitor&& visitor, Variants&&... variants);

Visits a ts::basic_variant.

Effects: Effectively calls visitor(variants.value(variant_type<Ts>{})...), where Ts... are the types of the currently active element in the variant, i.e. it calls the operator() of the visitor where the ith argument is the currently stored value in the ith variant, perfectly forwarded. If the ith variant is empty and it allows the empty state, it passes nullvar as parameter, otherwise the behavior is undefined. If the particular combination of types is not overloaded, the program is ill-formed, unless the Visitor provides a member named incomplete_visitor, then visit() does not do anything instead of the error. \returns The result of the chosen operator(), its the type is the common type of all possible combinations. \exclude return \module variant